package com.qlshouyu.len44;

import com.qlshouyu.len44.models.Address;
import com.qlshouyu.len44.models.IUser;
import com.qlshouyu.len44.models.User;
import com.qlshouyu.len44.models.User1;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TODO
 *
 * @author 高露 邮箱：<a href="egojit@qq.com">egojit@qq.com</a>
 * @since 2019-11-03 07:37
 */
@Configuration
public class AutoConfiguration {


    @Bean
    public Address address(){
        Address a=new Address();
        a.setName("安徽");
        return a;
    }

//    @Bean
//    public IUser user(){
//        User u=new User();
//        u.setName("高露");
//        return u;
//    }

    @Bean
//    @ConditionalOnBean(value = {Address.class})
//    @ConditionalOnMissingBean(value = IUser.class)
    @ConditionalOnProperty(name = "qlshouyu.name",matchIfMissing = false)
//    @ConditionalOnClass(value = Address.class)
    public IUser user1(Address address){
        User1 u=new User1();
        u.setName("高露");
        u.setAddress(address);
        return u;
    }



}
